package cn.com.nes.site.controller.project;

import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.vo.project.*;
import cn.com.nes.site.service.equipment.archives.PersonalProjectManageService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 个人项目接口
 */
@Slf4j
@Controller
@RequestMapping("/v2/project/personal")
public class PersonalProjectManageController {

    @Resource
    private PersonalProjectManageService personalProjectManageService;

    @ApiOperation(value = "删除个人项目", notes = "按地点删除（可批量）")
    @RequestMapping(value = "/deletePersonalProject", method = RequestMethod.POST)
    public @ResponseBody PageData deletePersonalProject(@RequestBody PersonalProjectDeleteVo vo) throws Exception {
        return personalProjectManageService.deletePersonalProject(vo);
    }

    @ApiOperation("查询项目详情")
    @RequestMapping(value = "/getPersonalProjectDetails", method = RequestMethod.GET)
    public @ResponseBody PageData getPersonalProjectDetails(PersonalProjectDetailsQueryVo vo) throws Exception {
        return personalProjectManageService.getPersonalProjectDetails(vo);
    }

    @ApiOperation("查询个人项目列表-分页")
    @RequestMapping(value = "/pagePersonalProject", method = RequestMethod.POST)
    public @ResponseBody PageData pagePersonalProject(@RequestBody PersonalProjectPageVo vo) throws Exception {
        return personalProjectManageService.pagePersonalProject(vo);
    }

    @ApiOperation("添加个人项目(清洁取暖)")
    @RequestMapping(value = "/savePersonalProjectForClean", method = RequestMethod.POST)
    public @ResponseBody PageData savePersonalProjectForClean(
            @RequestBody @Validated PersonalProjectSaveForCleanVo vo) throws Exception {
        log.debug("工程管理 - 项目管理 - 个人项目（清洁取暖） - 设备档案保存");
        return personalProjectManageService.savePersonalProjectForClean(vo);
    }

    @ApiOperation("添加个人项目(设备厂商)")
    @RequestMapping(value = "/savePersonalProjectForManufacture", method = RequestMethod.POST)
    public @ResponseBody PageData savePersonalProjectForManufacture(
            @RequestBody @Validated PersonalProjectSaveForManufactureVo vo) throws Exception {
        log.debug("工程管理 - 项目管理 - 个人项目（设备厂商） - 设备档案保存");
        return personalProjectManageService.savePersonalProjectForManufacture(vo);
    }

    @ApiOperation("获取清洁取暖字典下拉选")
    @RequestMapping(value = "/getCtceDicSelect", method = RequestMethod.GET)
    public @ResponseBody PageData getCtceDicSelect(@RequestParam(value = "dicType") String dicType) throws Exception {
        log.debug("工程管理 - 项目管理 - 个人项目（清洁取暖） - 字典下拉选");
        return PageData.ok(personalProjectManageService.getCtceDicSelect(dicType), true);
    }

    @ApiOperation("查询清洁取暖的所有字典")
    @RequestMapping(value = "/getCtceDicAll", method = RequestMethod.GET)
    public @ResponseBody PageData getCtceDicAll() throws Exception {
        log.debug("工程管理 - 项目管理 - 个人项目（清洁取暖） - 所有字典");
        return PageData.ok(personalProjectManageService.getCtceDicAll(), true);
    }

    @ApiOperation("安装协议分页查询")
    @RequestMapping(value = "/pageInstallProtocal", method = RequestMethod.GET)
    public @ResponseBody PageData pageInstallProtocal(InstallProtocalPageVo vo) throws Exception {
        log.debug("工程管理 - 项目管理 - 个人项目（清洁取暖） - 安装协议分页列表");
        return personalProjectManageService.pageInstallProtocal(vo);
    }

    @ApiOperation("施工计划分页查询")
    @RequestMapping(value = "/pageConstructionPlan", method = RequestMethod.GET)
    public @ResponseBody PageData pageConstructionPlan(ConstructionPlanPageVo vo) throws Exception {
        log.debug("工程管理 - 项目管理 - 个人项目（清洁取暖） - 施工计划分页列表");
        return personalProjectManageService.pageConstructionPlan(vo);
    }


}
